f = open('政府报告1.txt', 'r', encoding='utf-8')
print(f.read())


with open('222.txt','r',encoding='utf-8')as ff:
    text = ff.read()
    print(text)



fff=open(r'C:\Users\Administrator\Desktop\政府报告1.txt',encoding='utf-8')
print(fff.read())

fff=open('333.txt','w',encoding='utf-8')
fff.write('hello world, hello python!')
fff.close()

date='你好，今天天气不好！'
with open('333.txt','a',encoding='utf-8') as f:
    f.write(date)

    # import pandas as pd
# df =pd.read_excel(r'C:\Users\Administrator\Desktop\111.xlsx')
# print(df)
# # 写文件到excle
# a1={'姓名':'xiaoli','年龄':19}
# a2={'姓名':'xiaozhao','年龄':20}
# a3={'姓名':'xiaotao','年龄':25}
# l1=[a1,a2,a3]
# print(l1)
#
# df1=pd.DataFrame(l1)
# print(df1)
# df1.to_excel('222.xlsx',index=False)

# 处理word文档需要下载python-docx
# 导入docx库的Document模块
from docx import Document
#打开docx文档
doc=Document('2023年国务院政府工作报告.docx')
print(doc)
# 使用word段落使用paragraphs，得到的是列表len（）计算列表元素个数
p=doc.paragraphs
print(p)
print(len(p))
# 遍历列表，显示段落内容使用text
for i in p:
    print(i.text)